<?php
/**
 * Created by PhpStorm.
 * User: wjj
 * Date: 2016/11/1
 */

namespace app\logic;


use app\models\Advertisement;
use app\models\Article;
use app\models\Category;
use app\models\Comment;
use app\models\CommentTrends;
use app\models\Industry;
use app\models\Region;
use app\models\Tag;
use app\models\Trends;
use app\models\Company;
use app\models\Investor;
use app\models\OpenHistory;
use app\models\User;
use yii;
use yii\db\Query;

use JPush\Client as JPush;

class CommonLogic
{
    public function getAdvertisement($type)
    {
        //return Advertisement::findOne(['position'=>$type,'status'=>1])->toArray();
        return Advertisement::find()->where(['position'=>$type,'status'=>1])->asArray()->all();
    }

    public function getAdvById($adv_id){
        return Advertisement::findOne(['ad_id'=>$adv_id])->toArray();
    }

    public function getAdvertisementDetail($advertisement_id)
    {
        return Advertisement::findOne(['advertisement_id'=>$advertisement_id,'status'=>1]);
    }

    public function getArticle($article_id=0){
        if($article_id){
            return Article::findOne(['article_id'=>$article_id,'status'=>1])->toArray();
        }else{
            return Article::findOne(['status'=>1])->toArray();
        }

    }

    public function getQuestion(){
        return Article::find()->where(['type'=>0,'status'=>1])->asArray()->all();
    }


}